package com.atguigu.guli.service.base.exception;

import com.atguigu.guli.service.base.result.ResultCodeEnum;
import lombok.Data;

@Data
//自定义异常类
public class GuLiException extends RuntimeException {
    //自定义的错误码
    private Integer code;


    //接收自定义枚举类型
    public GuLiException(ResultCodeEnum resultCodeEnum) {
        //赋值自定义异常getMessage到父类的detailMessage显示到控制台
        super(resultCodeEnum.getMessage());

        this.code = resultCodeEnum.getCode();
    }


//接收状态吗和消息的方式
/*    public GuLiException(String message, Integer code) {
        //赋值自定义异常到父类
        super(message);
        this.code = code;
    }*/

    @Override
    public String toString() {
        return "GuLiException{" +
                "code=" + code +
                "message"+this.getMessage()+
                '}';
    }
}
